import java.util.Arrays;

/**
 * @Author ZhangCuirong
 * @Date 2025/10/11 10:24
 * @description:
 */
public class Solution673 {
    public int findNumberOfLIS(int[] nums) {
        int[] dp = new int[nums.length + 1];
        int[] count = new int[nums.length + 1];
        Arrays.fill(dp, 1);
        Arrays.fill(count, 1);
        int res = 0;
        int max = 1;

        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    if (dp[j] + 1 > dp[i]) {
                        dp[i] = dp[j] + 1;
                        count[i] = count[j];
                    } else if (dp[j] + 1 == dp[i]) {
                        count[i] += count[j];
                    }
                }
            }
            max = Math.max(max, dp[i]);

        }
        for (int i = 0; i < nums.length; i++) {
            if (dp[i] == max) {
                res += count[i];
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Solution673 solution = new Solution673();
        System.out.println(solution.findNumberOfLIS(new int[]{1, 3, 5, 4, 7}));//2
        System.out.println(solution.findNumberOfLIS(new int[]{2, 2, 2, 2, 2}));//5
        System.out.println(solution.findNumberOfLIS(new int[]{1, 2, 4, 3, 5, 4, 7, 2}));//3  1,2,3,5,7  1,2,4,5,7  1,2,3,4,7
    }
}
